<?php

require_once "mysql_info.php";

if (isset($_GET['keywords'])) {
  $db_server = mysql_connect($db_hostname, $db_username, $db_password);

  $keywords = mysql_real_escape_string($_GET['keywords'], $db_server);

  $result = db_access("SELECT * FROM listings WHERE " .
    "MATCH(title, description) " .
    "AGAINST ('" . $keywords .
    "' IN BOOLEAN MODE)", $db_server);

  echo "<ul>";
  for ($i = 0; $i < mysql_num_rows($result); $i++) {
    echo "<li>";
    foreach (array("title", "description", "latitude", "longitude") as $item) {
      echo mysql_result($result, $i, $item) . "<br/>";
    }
    echo "</li>";
  }
  echo "</ul>";
} else {
  echo ("The 'keywords' argument is missing.");
}

?>
